<?php
//////////// assigned vars to replace /////////////
$title = $this->title;
$drafts = $this->drafts;
$other_drafts = $this->other_drafts;
$arc_result = $this->arc_result;
$posts_columns = $this->posts_columns;
$posts = $this->posts;

//////////////////////////////////////////////////
$uri_array= array(
		'option'		=> JRequest::getWord('option'),
		'task'			=> $task,
		'controller'	=> JRequest::getWord('controller'),
	);
	$uri =& JURI::getInstance(); 
	$uri->setQuery($uri_array); 
	
///////////////////////////////////////////////////

if ($drafts || $other_drafts) {
			?>
	<div class="wrap">
		<?php
		if ($drafts) { 
		?>
			<p><strong>
			<?php 
			JText::_('Your Drafts: ');
			//_e('Your Drafts:') 
			?>
			</strong>
			<?php
			$i = 0;
			foreach ($drafts as $draft) {
				if($i != 0){ echo ', '; }				
				$draft->post_title = stripslashes($draft->post_title);
				if ($draft->post_title == ''){
					$draft->post_title = sprintf(__('Post #%s'), $draft->ID);					
				}
				$text = $draft->post_title;
				$attribs = array('title',JText::_('Edit this draft'));
				$uri->set('task','edit');
				$uri->set('post',$draft->ID);
				$uri->set('controller','post');
				echo JHTML::_('link',$uri->toString(),$text,$attribs);
				//echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
				++$i;
			}
			?>
			.</p>
		<?php
		}//end if $drafts
		
		if($other_drafts){
		?>
			<p><strong>
			<?php
			JText::_('Other&#8217;s Drafts: ');
			// _e('Other&#8217;s Drafts:') 
			?>
			</strong>
			<?php
			$i = 0;
			foreach ($other_drafts as $draft) {
				if($i != 0){ echo ', '; }				
				$draft->post_title = stripslashes($draft->post_title);
				if ($draft->post_title == ''){
					$draft->post_title = sprintf(__('Post #%s'), $draft->ID);					
				}$text = $draft->post_title;
				$attribs = array('title',JText::_('Edit this draft'));
				$uri->set('task','edit');
				$uri->set('post',$draft->ID);
				$uri->set('controller','post');
				echo JHTML::_('link',$uri->toString(),$text,$attribs);
				//echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
				++$i;
			}
			?>
			.</p>
		<?php
		}//end $other_drafts
		?>
	</div>
<?php 
}//end if $drafts or $other_drafts
?>
<div class="wrap">
<h2><?php
if ( is_month() ) {
	single_month_title(' ');
} elseif ( is_search() ) {
	printf(__('Search for &#8220;%s&#8221;'), wp_specialchars($_GET['s']) );
} else {
	if ( is_single() )
	printf(__('Comments on %s'), $post->post_title);
	elseif ( ! is_paged() || get_query_var('paged') == 1 )
	_e('Last 15 Posts');
	else
	_e('Previous Posts');
}
?>
</h2>
<form name="searchform" action="" method="get"
	style="float: left; width: 16em; margin-right: 3em;">
<fieldset><legend><?php _e('Search Posts&hellip;') ?></legend> <input
	type="text" name="s"
	value="<?php if (isset($s)) echo wp_specialchars($s, 1); ?>" size="17" />
<input type="submit" name="submit" value="<?php _e('Search') ?>" /></fieldset>
</form>
<?php
if ( count($arc_result) ) { ?>

<form name="viewarc" action="" method="get"
	style="float: left; width: 20em; margin-bottom: 1em;">
<fieldset><legend><?php _e('Browse Month&hellip;') ?></legend> <select
	name='m'>
	<?php
	foreach ($arc_result as $arc_row) {
		$arc_year  = $arc_row->yyear;
		$arc_month = $arc_row->mmonth;
			
		if( isset($_GET['m']) && $arc_year . zeroise($arc_month, 2) == (int) $_GET['m'] )
		$default = 'selected="selected"';
		else
		$default = null;
			
		echo "<option $default value=\"" . $arc_year.zeroise($arc_month, 2) . '">';
		echo $month[zeroise($arc_month, 2)] . " $arc_year";
		echo "</option>\n";
	}
	?>
</select> <input type="submit" name="submit"
	value="<?php _e('Show Month') ?>" /></fieldset>
</form>

<?php 
}
?>
<br style="clear: both;" />
<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
	<tr>

	<?php foreach($posts_columns as $column_display_name) { ?>
				<th scope="col"><?php echo $column_display_name; ?></th>
		<?php 
		}
		?>
	</tr>
	<?php
	if ($posts) {
		jimport('joomla.utilities.date');
		
		$bgcolor = '';
		foreach ($posts as $post) {
			//start_wp();
			$class = ('alternate' == $class) ? '' : 'alternate';
	?>
	<tr id='post-<?php echo $post->id; ?>' class='<?php echo $class; ?>'>
		<th scope="row"><?php echo $post->id ?></th>
		<td><?php $jdate = new JDate($post->date); echo $jdate->toFormat();?></td>
		<td><?php $post->title; //TODO: iron our how wp uses individual passwd on post; ?> <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
		<td><?php $post->categories//TODO: the_category(','); ?></td>
		<td><a href="edit.php?p=<?php echo $id ?>&amp;c=1"> <?php comments_number(__('0'), __('1'), __('%')) ?></a></td>
		<td><?php $post->author; //TODO: the_author() ?></td>
		<td><a href="<?php $post->permalink; //TODO: the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
		<td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$post->id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
		<td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), get_the_title('', '')) . "');\">" . __('Delete') . "</a>"; } ?></td>
		<td><?php do_action('manage_posts_custom_column', $column_name, $post->id); ?></td>
	</tr>
	<?php	
		
		/*
		foreach($posts_columns as $column_name=>$column_display_name) {
		switch($column_name) {
			case 'id':	?>
		<th scope="row"><?php echo $id ?></th>
		<?php break;
		case 'date':
		?>
		<td><?php the_time('Y-m-d \<\b\r \/\> g:i:s a'); ?></td>
		<?php
		break;
		case 'title':
		?>
		<td><?php the_title() ?> <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
		<?php
		break;
		case 'categories':
		?>
		<td><?php the_category(','); ?></td>
		<?php
		break;
		case 'comments':
		?>
		<td><a href="edit.php?p=<?php echo $id ?>&amp;c=1"> <?php comments_number(__('0'), __('1'), __('%')) ?>
		</a></td>
		<?php
		break;
		case 'author':
		?>
		<td><?php the_author() ?></td>
		<?php
		break;
		case 'control_view':
		?>
		<td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
		<?php
		break;
		case 'control_edit':
		?>
		<td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
		<?php
		break;
		case 'control_delete':
		?>
		<td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), get_the_title('', '')) . "');\">" . __('Delete') . "</a>"; } ?></td>
		<?php
		break;
		default:
		?>
		<td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
		<?php
		break;
		}
*/
	}
} else {
	?>
	<tr style='background-color: <?php echo $bgcolor; ?>'>
		<td colspan="8"><?php _e('No posts found.') ?></td>
	</tr>
	<?php
} // end if ($posts)
?>
</table>

			